home *** CD-ROM | disk | FTP | other *** search
- Path: newsstand.tc.umn.edu!dyue
- From: dyue@cs.umn.edu (Dongxiao Yue)
- Newsgroups: comp.lang.c++
- Subject: Re: When to use "->" vs "." when calling Member functions
- Date: 17 Jan 1996 23:01:20 GMT
- Organization: University of Minnesota
- Message-ID: <4djv40$jpa@epx.cis.umn.edu>
- References: <4dhea1$6v8@ornews.intel.com> <30FCB569.41C67EA6@intellektik.informatik.th-darmstadt.de>
- NNTP-Posting-Host: exa.cs.umn.edu
-
- Enno Sandner <enno@intellektik.informatik.th-darmstadt.de> writes:
-
- >Thurman Miller wrote:
- >>
- >> I'm confused, so please no harsh remarks :)
- >>
- >> If I've got:
- >>
- >> class Cfoo
- >> {
- >> something * getptr();
- >> somethingelse* m_other;
- >> }
- >>
- >> something * foo::getptr()
- >> {
- >> return m_other;
- >> }
- >>
- >> Now...if I'm in another class....
- >>
- >> Cfoo foo;
- >> somethingelse* = foo.getptr();
- >>
- >> why doesn't the following work?
- >>
- >> somethingelse* = foo->getptr();
- >>
- >> I get compile error about no "->" overloaded operator....
- >>
- >> Can someone point out the obvious when I use one notation over
- >> another?
- >>
-
- >If you want to use 'foo.f' where 'f' is some member of a class,
- >'foo' must be an instance or reference to that class. If 'foo'
- >is a pointer to a class you must use 'foo->f' to access the member 'f'.
-
- > Enno
-
- When you see foo->f, foo may not be a pointer.
-